#include "mainwindow.h"
#include <QApplication>
#include <QThread>

QString tempdatabasepath;
QTranslator translator;
//QString theocbaseDirPath;

QSettings settings("./theocopy.ini", QSettings::IniFormat);

int main(int argc, char *argv[])
{

//bool firsttime = true;

    QApplication a(argc, argv);
    QString filename = "";
    QString file;
    QString path = a.applicationDirPath();
    filename = path + "/theocopy_";
    //suomenkieli on 0
    //englanti on 1
    if(settings.value("language","") == 0){
        //QMessageBox::warning(0,"Tiedosto","Tiedosto "+file);
        if(!QFile::exists(file)){
            file = filename+ "fi"+".qm";
            //QMessageBox::warning(0,"Tiedosto","Tiedosto löytyy "+file);
           }
    //englanti
    }else if(settings.value("language","") == 1){
        if(!QFile::exists(file)){
            file = filename+ "en"+".qm";
           }
    }else{

    }
    translator.load(QString(file));
    a.installTranslator(&translator);

    // set locale for date format
#ifdef Q_OS_LINUX
    // linux
    QString localeName = QLocale::languageToString(QLocale::system().language());
    QLocale loc = QLocale(QLocale::system().language());
    QLocale::setDefault(loc);
    qDebug() << "Linux system - locale:" << localeName;
#endif

    MainWindow w;
    //w.showFullScreen();
    w.showMaximized();
    w.show();


    return a.exec();
}

